﻿using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests;
using JoyfulHomeJourney.BackEnd.Infrastructure.Tools;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
    [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { new string[] { "admin", "carShop" } })]
    public class UploadController : BaseController
    {
        private readonly IUploadServer _uploadServer;

        public UploadController(IUploadServer uploadServer)
        {
            _uploadServer = uploadServer;
        }
        /// <summary>
        /// 产品图片上传
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { new string[] { "admin","carShop" } })]
        [HttpPost]
        public async Task<IActionResult> UploadProductImage([FromForm]RequestUploadDto dto)
        {
            return Send(await _uploadServer.UploadProductImage(dto));
        }
    }
}
